﻿using MovingChameLibrary.EnumTypes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MovingChameLibrary.Models
{
    public class Schedule : CommonItemModel, IComparable
    {
        public Schedule(int id, String title, String subtitle, byte[] imageStream,
            double longitude, double latitude, DateTime startTime, DateTime endTime, int dateOrder, Tour tour)
            : base(id, title, subtitle, imageStream)
        {
            this._longitude = longitude;
            this._latitude = latitude;
            this._state = LocationState.WillVisit;
            this._dateOrder = dateOrder;
            this._startTime = startTime;
            this._endTime = endTime;
            this._tour = tour;
        }

        private String _foregroundColor = "DarkGreen";
        public String ForegroundColor
        {
            get { return this._foregroundColor; }
            set { this.SetProperty(ref this._foregroundColor, value, "ForegroundColor"); }
        }

        private Tour _tour;
        public Tour Tour
        {
            get { return this._tour; }
            set { this.SetProperty(ref this._tour, value, "Tour"); }
        }

        private int _dateOrder = 1;
        public int DateOrder
        {
            get { return this._dateOrder; }
            set { this.SetProperty(ref this._dateOrder, value, "DateOrder"); }
        }

        private DateTime _startTime = DateTime.UtcNow;
        public DateTime StartTime
        {
            get { return this._startTime; }
            set { this.SetProperty(ref this._startTime, value, "StartTime"); }
        }

        private DateTime _endTime = DateTime.UtcNow;
        public DateTime EndTime
        {
            get { return this._endTime; }
            set { this.SetProperty(ref this._endTime, value, "EndTime"); }
        }

        private LocationState _state = LocationState.WillVisit;
        public LocationState State
        {
            get { return this._state; }
            set { this.SetProperty(ref this._state, value, "State"); }
        }

        private double _longitude = int.MinValue;
        public double Longitude
        {
            get { return this._longitude; }
            set { this.SetProperty(ref this._longitude, value, "Longitude"); }
        }

        private double _latitude = int.MinValue;
        public double Latitude
        {
            get { return this._latitude; }
            set { this.SetProperty(ref this._latitude, value, "Latitude"); }
        }

        public int CompareTo(object anotherLocation)
        {
            if (!(anotherLocation is Schedule))
                return 1;
            if ((Latitude != (anotherLocation as Schedule).Latitude) && (Longitude != (anotherLocation as Schedule).Longitude))
                return 1;
            return 0;
        }
    }
}
